package com.atguigu.rabbitmq.two;

import com.atguigu.rabbitmq.utils.RabbitMqUtils;
import com.rabbitmq.client.*;

import java.io.IOException;
import java.util.concurrent.TimeoutException;

public class Worker01 {
    private static final String QUEUE_NAME="hello";

    public static void main(String[] args) throws IOException, TimeoutException {
        Channel channel = RabbitMqUtils.getChannel();
        System.out.println("C2等待接受消息.......");
        /**
         *消费者消费消息*
         1消费哪个队列
         2消费成功之后是否要自动应答true代表自动应答false手动应答
         3.消费者未成功消费的回调
         */
        channel.basicConsume(QUEUE_NAME, true,(consumerTag,message)->{
            System.out.println("接收到的消息"+new String(message.getBody()));
        },consumerTag->{
            System.out.println(consumerTag+"消息着取消消费接口回调逻辑");
        });
    }
}
